package com.example.myapplicationtest;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
 
public class JNIDynamic extends Activity implements OnClickListener {
	private static final String TAG = "MainActivity";
	private TextView show;
	private Button getInt, getString, getIntArray, getBool, getBackIntArray,
			getBackStrArray, getObject;
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dynamic);
		init();
	}
 
	private void init() {
		show = (TextView) this.findViewById(R.id.show);
		getInt = (Button) this.findViewById(R.id.getint);
		getInt.setOnClickListener(this);
		getIntArray = (Button) this.findViewById(R.id.getintarray);
		getIntArray.setOnClickListener(this);
		getString = (Button) this.findViewById(R.id.getstring);
		getString.setOnClickListener(this);
		getBool = (Button) this.findViewById(R.id.getbool);
		getBool.setOnClickListener(this);
		getBackIntArray = (Button) this.findViewById(R.id.getBackIntArray);
		getBackIntArray.setOnClickListener(this);
		getBackStrArray = (Button) this.findViewById(R.id.getBackStrArray);
		getBackStrArray.setOnClickListener(this);
		getObject = (Button) this.findViewById(R.id.getObject);
		getObject.setOnClickListener(this);
	}
 
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.getint:
			int intBack = JNIClient2.getInstance().AddInt(10, 10);
			showInfo(intBack);
			break;
		case R.id.getintarray:
			int intArr = JNIClient2.getInstance().intArrayMethod(
					new int[] { 2, 5, 8 });
			showInfo(intArr);
			break;
		case R.id.getbool:
			boolean bool = JNIClient2.getInstance().booleanMethod(true);
			showInfo(bool);
			break;
		default:
			break;
		}
	}

	private void showInfo(Object object) {
		show.setText("" + object);
		Log.i(TAG, "返回的信息-->" + object);
	}


}


